Hi .
Here is my example .. working with my code for Relay board 32 relay by I2C IO expander.
#include <MySensor.h>
#include <SPI.h>
// Define version
#define VSN "v1.0"
// Define Name
#define NAME "Test"
// Define Sensor - button
#define BLU 1 // Button Left Up
#define BLD 2 // Button Left Down
#define BRU 3 // Button Right Up
#define BRD 4 // Button Right Down
// Sensor objects
MySensor gw;
void setup() {
// eeprom_write_byte((uint8_t*)EEPROM_NODE_ID_ADDRESS, (byte)255);
gw.begin(incomingMessage,AUTO); // Node ID auto .. if not used gateway , Node ID must define manualy
gw.sendSketchInfo( NAME, VSN ); // Name and version
gw.present(BLU, S_LIGHT);
gw.present(BLD, S_LIGHT);
gw.present(BRU, S_LIGHT);
gw.present(BRD, S_LIGHT);
}
void loop()
{
gw.process();
}
void incomingMessage(const MyMessage &message) {
if (message.type == V_LIGHT) {
MyMessage response (message.getByte(),V_LIGHT) ; // message.getByte() = payload define what relay want change state
response.setDestination(1); // My Relay Board
gw.send(response);
}
}```